#include "StdDevice.h"
#include "StdDevice_common.h"

void StdDevice___init__(PikaObj *self){
    // GPIO常量
    obj_setInt(self, "PULL_NONE", 1);
    obj_setInt(self, "PULL_UP", 2);
    obj_setInt(self, "PULL_DOWN", 3);

    obj_setInt(self, "MODE_IN", 1);
    obj_setInt(self, "MODE_OUT", 2);
    obj_setInt(self, "MODE_OD", 3);
    obj_setInt(self, "MODE_IRQ", 4);

    obj_setInt(self, "IRQ_RISING", 1);
    obj_setInt(self, "IRQ_FALLING", 2);
    obj_setInt(self, "IRQ_BOTH", 3);

    obj_setInt(self, "HIGH", 1);
    obj_setInt(self, "LOW", 0);

    // UART常量
    obj_setInt(self, "FLOW_CONTROL_NONE", PIKA_HAL_UART_FLOW_CONTROL_NONE);
    obj_setInt(self, "FLOW_CONTROL_RTS", PIKA_HAL_UART_FLOW_CONTROL_RTS);
    obj_setInt(self, "FLOW_CONTROL_CTS", PIKA_HAL_UART_FLOW_CONTROL_CTS);
    obj_setInt(self, "FLOW_CONTROL_RTS_CTS", PIKA_HAL_UART_FLOW_CONTROL_RTS_CTS);
               
    obj_setInt(self, "SIGNAL_RX", PIKA_HAL_UART_EVENT_SIGNAL_RX);
    obj_setInt(self, "SIGNAL_TX", PIKA_HAL_UART_EVENT_SIGNAL_TX);

    obj_setInt(self, "STOP_BITS_1", PIKA_HAL_UART_STOP_BITS_1);
    obj_setInt(self, "STOP_BITS_2", PIKA_HAL_UART_STOP_BITS_2);
    obj_setInt(self, "STOP_BITS_1_5", PIKA_HAL_UART_STOP_BITS_1_5);
    obj_setInt(self, "PARITY_NONE", PIKA_HAL_UART_PARITY_NONE);
    obj_setInt(self, "PARITY_ODD", PIKA_HAL_UART_PARITY_ODD);
    obj_setInt(self, "PARITY_EVEN", PIKA_HAL_UART_PARITY_EVEN);

    //SPI常量
    obj_setInt(self, "MASTER", PIKA_HAL_SPI_MASTER);
    obj_setInt(self, "SLAVE", PIKA_HAL_SPI_SLAVE);
    obj_setInt(self, "MODE_0", PIKA_HAL_SPI_MODE_0);
    obj_setInt(self, "MODE_1", PIKA_HAL_SPI_MODE_1);
    obj_setInt(self, "MODE_2", PIKA_HAL_SPI_MODE_2);
    obj_setInt(self, "MODE_3", PIKA_HAL_SPI_MODE_3);
    obj_setInt(self, "LSB", PIKA_HAL_SPI_LSB);
    obj_setInt(self, "MSB", PIKA_HAL_SPI_MSB);
    obj_setInt(self, "DATA_WIDTH_8", PIKA_HAL_SPI_DATA_WIDTH_8);
    obj_setInt(self, "DATA_WIDTH_16", PIKA_HAL_SPI_DATA_WIDTH_16);
    obj_setInt(self, "HALF_DUPLEX", 1);
    obj_setInt(self, "FULL_DUPLEX", 2);
}
